package com.gxc.service.log.controller;

import com.gxc.service.common.model.ServerResponse;
import com.gxc.service.log.entity.RequestInfoLogEntity;
import com.gxc.service.log.repository.RequestInfoLogRepository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 请求日志Controller.
 *
 * @author GongXincheng
 * @since 2019-11-09 02:53
 */
@RestController
@RequestMapping("/request/log")
public class RequestInfoLogController {

    @Resource
    private RequestInfoLogRepository requestInfoLogRepository;

    @GetMapping("/{requestId}")
    public ServerResponse<List<RequestInfoLogEntity>> findByRequestId(@PathVariable String requestId) {
        return ServerResponse.ok(requestInfoLogRepository.findByRequestIdOrderByIdDesc(requestId));
    }

}
